package com.karolak.rs;

//import com.karolak.entity.Person;

import java.util.Date;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/person")
public class EntityRestService {

	@GET
	@Path("/find/{id}")
	@Produces( { MediaType.APPLICATION_XML })
	public Person find(@PathParam("id") Integer id) {
		Person person = new Person();
		person.setId(id);
		String msg = "Searching for person id:" + id + " at " + new Date() + ".";
		System.out.println("Fouund person:" + person);
		return person;
	}

	@GET
	@Path("/findXml")
	@Produces( { MediaType.TEXT_XML })
	public String findPersonXml() {
		String msg = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><root><msg>Hello World at " + new Date() + "</msg></root>";
		return msg;
	}

	@GET
	@Path("/findHtml")
	@Produces( { MediaType.TEXT_HTML })
	public String findPersonJson() {
		String msg = "<html><body>Hello World at " + new Date() + "</body></html>";
		return msg;
	}
}
